//
//  XMLUnitParser.m
//  LanguagesTeach
//
//  Created by Niel Santos on 2/9/13.
//  Copyright 2013 __MyCompanyName__. All rights reserved.
//

#import "XMLUnitParser.h"
#import "MetaSubject.h"


@implementation XMLUnitParser

@synthesize metaSubjects;

- (void)parser:(NSXMLParser *)parser 
didStartElement:(NSString *)elementName
  namespaceURI:(NSString *)namespaceURI
 qualifiedName:(NSString *)qualifiedName
	attributes:(NSDictionary *)attributeDict{
	
	MetaSubject *metaSubject;
	
	if([elementName isEqualToString:@"unit"]) {
		//Treat levels
		metaSubjects = [[NSMutableArray alloc] init];
	}else if([elementName isEqualToString:@"subject"]) {
		metaSubject = [[MetaSubject alloc] init];
		metaSubject.title = [attributeDict objectForKey:@"title"];
		metaSubject.folder = [attributeDict objectForKey:@"folder"];
		[metaSubjects addObject: metaSubject];
		[metaSubject release];
	}
}


- (void)dealloc {
	[metaSubjects release];
    [super dealloc];
}

@end
